<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Title</title>
    <style>
        [v-cloak]{
            display: none;
        }
        .active{
            color: red;
        }
    </style>
</head>
<body>
<div id="app" v-cloak>
    <ul>
        <li :class="{active:index===currentIndex}"
        v-on:click="liClick(index)"
        v-for="(item,index) in movies">
            {{item}}
        </li>
    </ul>
</div>

<script src="https://unpkg.com/vue@3"></script>
<script>
    const app=Vue.createApp({
        data(){
            return{
                movies:['星际穿越','阿凡达','大话西游','黑客帝国'],
                currentIndex:-1
            }
        },
        methods:{
            liClick(index){
                console.log("liClick:",index)
                this.currentIndex=index
            }
        }
    })
    app.mount("#app")
</script>
</body>
</html>